Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




clear( ) FUNCTION


The 'clear( )' Function can be used to remove all the elements from the Dictionary.


Example :


clear() print(x)


Output :



  { }

So, in the above code we have created a 'Dictionary' using braces '{ }' and 'Key' and 'Value' pairs.


x = {
    5 : "Is a Number", 
    "John": "Is a Name", 
    "Python": "Is a Language"
}

And initialised to the variable 'x'.


java_Collections

And we have used the 'clear( )' method to remove all the elements from the 'Dictionary'.


x.clear( )

And the print statement, prints an empty 'Dictionary'.


Output :



  { }